<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="primus" tagdir="/WEB-INF/tags" %>
<primus:page title="品牌列表">
    <jsp:attribute name="css">
        <style type="text/css">

        </style>
    </jsp:attribute>
    <jsp:attribute name="script">
        <script type="application/javascript">
            $('.chosen-select').chosen({allow_single_deselect: true});
            //resize the chosen on window resize

            $(window)
                .off('resize.chosen')
                .on('resize.chosen', function () {
                    $('.chosen-select').each(function () {
                        var $this = $(this);
                        $this.next().css({'width': $this.parent().width()});
                    })
                }).trigger('resize.chosen');
            //resize chosen on sidebar collapse/expand
            $(document).on('settings.ace.chosen', function (e, event_name, event_val) {
                if (event_name != 'sidebar_collapsed') return;
                $('.chosen-select').each(function () {
                    var $this = $(this);
                    $this.next().css({'width': $this.parent().width()});
                })
            });
        </script>
    </jsp:attribute>
    <jsp:body>
        <%--<jsp:include page="../demo/cats/component/navigations.jsp"/>--%>
        <div class="breadcrumbs ace-save-state" id="breadcrumbs">
            <ul class="breadcrumb">
                <li>
                    <i class="ace-icon fa fa-home home-icon"></i>
                    <a href="welcome.do">
                        首页
                    </a>
                </li>
                <li>
                    商品管理
                </li>
                <li class="active">
                    品牌管理
                </li>
            </ul>
            <a class="btn btn-xs btn-primary history-back">
                <i class="ace-icon fa fa-angle-left"></i>
                返回
            </a>
        </div>

        <div class="page-content">
            <h3 class="header smaller lighter blue">
                品牌数据
            </h3>
            <div class="row">
                <div class="col-xs-12">
                    <form action="management/brand/save" method="post" class="form-horizontal" role="form">
                        <input type="hidden" name="id" value="${brand.id}">
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right" for="name">
                                所属分类
                            </label>
                            <div class="col-sm-9">
                                <select name="categoryIds" multiple="multiple" class="chosen-select" data-placeholder="选择父分类">
                                    <c:forEach var="item" items="${categories.content}">
                                        <option value="${item.id}"
                                                <c:forEach var="reqItem"
                                                           items="${brand.categoryIds}">
                                                    ${reqItem eq item.id?'selected':''}
                                                </c:forEach>
                                        >${item.name}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right" for="name">
                                品牌名称
                            </label>
                            <div class="col-sm-9">
                                <input id="name" type="text" name="name" readonly="readonly"
                                       placeholder="品牌名称"
                                       maxlength="255" minlength="1"
                                       value='<c:out value="${brand.name}"/>'
                                       class="required text col-xs-12 col-sm-12">

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right" for="idx">
                                排序
                            </label>

                            <div class="col-sm-9">
                                <input id="idx" type="number" name="idx"
                                       value='<c:out value="${brand.idx}"/>'
                                       class="required text col-xs-12 col-sm-12">

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right">
                                启用状态
                            </label>
                            <div class="col-sm-4">
                                <primus:statusSelect fieldName="status" selectedStatus="${brand.status}"/>
                            </div>
                        </div>
                        <sec:authorize access="hasAuthority('OPT_BRAND_UPDATE')">
                            <div class="clearfix form-actions">
                                <div class="col-md-offset-3 col-md-9">
                                    <button class="btn btn-info" type="submit" id="btn_save">
                                        <i class="ace-icon fa fa-check bigger-110"></i>
                                        保存
                                    </button>

                                    &nbsp; &nbsp; &nbsp;
                                    <button class="btn" type="reset">
                                        <i class="ace-icon fa fa-undo bigger-110"></i>
                                        重置
                                    </button>
                                </div>
                            </div>
                        </sec:authorize>
                    </form>
                </div>
            </div>
        </div>
    </jsp:body>
</primus:page>
